package com.example.module_vistor.visiternet.viewmodel

import android.util.Log
import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.viewModelScope
import com.example.lib_common.base.BaseViewModel
import com.example.lib_net.BaseResponse

import com.example.module_vistor.visiternet.VisiterModel
import com.example.module_vistor.visiternet.VisiterRePo
import dagger.hilt.android.lifecycle.HiltViewModel
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.catch
import kotlinx.coroutines.flow.collectLatest
import kotlinx.coroutines.flow.onStart
import kotlinx.coroutines.launch
import javax.inject.Inject

@HiltViewModel
class VisiterViewModel @Inject constructor(private val visiterRePo: VisiterRePo) : BaseViewModel() {


    val visiterfailedlivedata_ by lazy {
        MutableLiveData<String>()
    }
    val  visiterfailedlivedata get() = visiterfailedlivedata_
    val visitersuccesslivedata_ by lazy {
        MutableLiveData<VisiterModel>()
    }
    val  visitersuccesslivedata get() = visitersuccesslivedata_

    fun getVisiterInfo(userId: Int) {
        execute2(
            action = visiterRePo.getVisiterInfo(userId),
            onFinish = {
                visitersuccesslivedata_.value = it
            },
            onError = {
                visiterfailedlivedata.value = "暂无数据"
                Log.d("sss", "visiter2: " + it)
            }
        )


    }


}